<?php

class Default_Admin_GuestbookEditAction extends ProjectBaseAction
{
	public function executeRead(AgaviRequestDataHolder $rd)
	{
			$id = $rd->getParameter('gbid');
		$c = new Criteria();
		$c->add(AfgOMCommentPeer::ID,$id);
		$comment = AfgOMCommentPeer::doSelectOne($c);
		
		if($comment instanceof AfgOMComment && $comment->getId()==$id) {
			$commentArray = $comment->toArray();
			$this->setAttribute('comment',$commentArray);
			return 'Form';
		} else {
			return 'Error';
		}
	}
	 public function executeWrite(AgaviRequestDataHolder $rd)
	 {
	 	$id = $rd->getParameter('gbid');
		$c = new Criteria();
		$c->add(AfgOMCommentPeer::ID,$id);
		$afg = AfgOMCommentPeer::doSelectOne($c);
		
        $afg->setName($rd->getParameter('Name'));
		$afg->setEmail($rd->getParameter('Email'));
		$afg->setUrl($rd->getParameter('Url'));
		$afg->setMessage($rd->getParameter('Message'));
        $afg->save();
        
                
		return $this->executeRead($rd); 
	 }
	
	public function isSecure()
	{
		return true; 
	}
}

?>